package com.jt.permission.helper;

import com.jt.permission.model.Role;
import com.jt.permission.model.User;
import com.jt.permission.service.RoleService;
import com.jt.permission.service.UserService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 事务控制类。抛Exception时数据会回滚
 */
@Transactional(rollbackFor = Exception.class)
@Component
public class TransactionalHelper {
    @Resource
    private UserService sysUserService;
    @Resource
    private RoleService sysRoleService;


    public User saveOrUpdateUserRole(User user, List<Long> roleIdList) {
        return sysUserService.saveOrUpdateUserRole(user, roleIdList);
    }


    public Role saveOrUpdateRoleMenu(Role sysRole, List<Long> menuIdList) {
        return sysRoleService.saveOrUpdateRoleMenu(sysRole, menuIdList);
    }
}
